package com.gztms.blogmgnt.pojo;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gztms.usermgnt.pojo.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Zoey
 * @date 2023/4/22 21:31
 * @Description 文章类
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "blog")
@Accessors(chain = true)
public class Blog implements Serializable {

    private static final long serialVersionUID = -4953958200017930763L;

    @TableId(type = IdType.AUTO)
    private Integer bid;
    private String title;
    private String content;
    private String cover;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;
    @TableField(fill = FieldFill.UPDATE)
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;
    private Integer likeSum;
    private Integer favSum;
    private Integer viewCount;
    @TableField(fill = FieldFill.INSERT)
    private Integer status;
    @TableLogic
    @TableField(fill = FieldFill.INSERT)
    private Integer isDelete;
    private Integer type;
    @TableField(fill = FieldFill.INSERT)
    private String createdBy;
    private String checkedBy;
    /**
     * 关联字段
     */
    @TableField(exist = false)
    private User user;

    @TableField(exist = false)
    private String typeName;

    @TableField(exist = false)
    private String username;

    public Blog(Integer bid, Integer viewCount) {
        this.bid = bid;
        this.viewCount = viewCount;
    }
}
